/*
 * @Author: your name
 * @Date: 2021-12-21 17:06:27
 * @LastEditTime: 2022-02-17 14:42:20
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \etrip-ui\vite.config.js
 */
import { defineConfig } from 'vite'
const path = require('path')
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],

  build: {
    // outDir: 'lib',
    cssCodeSplit: true,
    // lib: {
    //   entry: path.resolve(__dirname, `packages/src/index.js`),
    //   name: 'MyLib',
    //   fileName: (format) => `my-lib.${format}.js`
    // },
    rollupOptions: [
      {
        input: path.resolve(__dirname, `packages/src/index.js`),
        // output: {
        //   file: 'lib/src/index.umd.js'
        // },
        // 确保外部化处理那些你不想打包进库的依赖
        external: ['vue'],
        output: {
          dir: 'lib',
          file: 'lib/src/index.umd.js',
          // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
          globals: {
            vue: 'Vue'
          }
        }
      }
    ]
      
  }
})
